package com.zjcode.cdcer.service.impl;

import com.chinatechstar.component.commons.service.BaseService;
import com.zjcode.cdcer.mapper.CerEndoscopicDiagnosisDetailsMapper;
import com.zjcode.cdcer.model.CerEndoscopicDiagnosisDetails;
import com.zjcode.cdcer.service.CerEndoscopicDiagnosisDetailsService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CerEndoscopicDiagnosisDetailsServiceImpl implements CerEndoscopicDiagnosisDetailsService, BaseService {

    @Autowired
    private CerEndoscopicDiagnosisDetailsMapper cerEndoscopicDiagnosisDetailsMapper;

    @Override
    public int batchInsert(List<CerEndoscopicDiagnosisDetails> cerEndoscopicDiagnosisDetailsList) {
        if (CollectionUtils.isEmpty(cerEndoscopicDiagnosisDetailsList)) {
            return 0;
        }
        int result = cerEndoscopicDiagnosisDetailsMapper.batchInsert(cerEndoscopicDiagnosisDetailsList);
        return Math.max(result, 0);
    }

    @Override
    public List<CerEndoscopicDiagnosisDetails> findByParentId(String parentId) {
        return cerEndoscopicDiagnosisDetailsMapper.findByParentId(parentId);
    }

    @Override
    public void deleteByParentId(String id) {
        cerEndoscopicDiagnosisDetailsMapper.deleteByParentId(id);
    }
}
